package com.IO.OutputStream;

import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * name：zhangwang
 * time：2025/3/11 21:16
 */
public class Test2 {
    public static void main(String[] args) throws Exception {
        //复制文件
        //先向内存中读到数据
        FileInputStream InputStream = new FileInputStream("C:\\Users\\25602\\Desktop\\虚拟机操作.png");
        //创建输出流
        FileOutputStream outputStream = new FileOutputStream("虚拟机.png");
        //一次读写一个字节数组
        byte[] bt = new byte[1024];
        int i;//记录的是每次真实读到数据的个数
        while ((i=InputStream.read(bt)) != -1){
            outputStream.write(bt,0,i);
        }
        //释放资源
        InputStream.close();
        outputStream.close();
    }
}
